Type.registerNamespace("Telerik.Web.UI.Widgets");
Type.registerNamespace("Telerik.Web.UI.Editor.DialogControls");
(function(){var b=$telerik.$;
var a=Telerik.Web.UI;
Telerik.Web.UI.Editor.DialogControls.FileManagerDialog=function(c){Telerik.Web.UI.Editor.DialogControls.FileManagerDialog.initializeBase(this,[c]);
};
Telerik.Web.UI.Editor.DialogControls.FileManagerDialog.registerClass("Telerik.Web.UI.Editor.DialogControls.FileManagerDialog",Telerik.Web.UI.RadWebControl,Telerik.Web.IParameterConsumer);
Type.registerNamespace("Telerik.Web.UI.Widgets");
Telerik.Web.UI.Widgets.FileManager=function(c){Telerik.Web.UI.Widgets.FileManager.initializeBase(this,[c]);
this._clientParameters=null;
};
Telerik.Web.UI.Widgets.FileManager.prototype={initialize:function(){Telerik.Web.UI.Widgets.FileManager.callBaseMethod(this,"initialize");
if(this.get_insertButton()){$addHandlers(this.get_insertButton(),{click:this._insertClickHandler},this);
this.get_insertButton().title=localization.Insert;
}if(this.get_cancelButton()){$addHandlers(this.get_cancelButton(),{click:this._cancelClickHandler},this);
this.get_cancelButton().title=localization.Cancel;
}if(this._fileBrowser!=null){this._fileBrowser.add_itemSelected(Function.createDelegate(this,this._browserItemClickHandler));
this._fileBrowser.add_fileOpen(Function.createDelegate(this,this._browserDoubleClickHandler));
this._fileBrowser.add_folderChange(Function.createDelegate(this,this._browserDirectoryChangeyHandler));
}},clientInit:function(c){this._clientParameters=c;
var d=this._getQueryStringParameter();
var e=null;
try{e=c.get_value();
}catch(f){}if(d&&e){this._initialItem=e;
}else{this._initialItem=null;
}},_getQueryStringParameter:function(){var e=location.search;
if(e){var d=e.substring(1,e.length);
var c="&PreselectedItemUrl=";
if(d.indexOf(c)!=-1){d=d.substring(d.indexOf(c)+c.length);
var f=d.indexOf("&");
if(f==-1){f=d.length-1;
}d=decodeURIComponent(d.substring(0,f));
return d;
}}return null;
},_stripProtocolAndServerName:function(d){var c=d.indexOf("//");
if(c>=0){c=d.indexOf("/",c+2);
if(c>=0){return d.substring(c);
}}return d;
},get_clientParameters:function(){return this._clientParameters;
},populateObjectProperties:function(c){this._filePreviewer.populateObjectProperties(c);
},get_selectedItem:function(){return this._fileBrowser.get_selectedItem();
},_insertClickHandler:function(){var g=this.get_selectedItem();
if(g&&g.get_type()==Telerik.Web.UI.FileExplorerItemType.File){var e=this._filePreviewer.getResult();
var f=this.get_previewerType();
var c=f?f.replace("Previewer","Manager"):"FileBrowser";
var d=new Telerik.Web.UI.EditorCommandEventArgs(c,null,e);
window.setTimeout(function(){Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(d);
},0);
}},_cancelClickHandler:function(){Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close();
},_browserDirectoryChangeyHandler:function(c,d){this.browserDirectoryChange(c,d);
},_browserItemClickHandler:function(c,d){this.browserItemClick(c,d);
},_browserDoubleClickHandler:function(c,d){this.browserItemClick(c,d);
this._insertClickHandler();
},currentDirPermissions:function(){return this._fileBrowser.get_currentPermissions();
},browserItemClick:function(c,d){this._filePreviewer.setItem(d.get_item());
this.enableButton(this.get_insertButton(),d.get_item().get_type()!=Telerik.Web.UI.FileExplorerItemType.Directory);
},browserDirectoryChange:function(c,d){this._filePreviewer.setItem(d.get_item());
this.enableButton(this.get_insertButton(),d.get_item().get_type()!=Telerik.Web.UI.FileExplorerItemType.Directory);
},enableButton:function(d,c){if(d==null){return;
}Telerik.Web.UI.RadFormDecorator.set_enabled(d,c);
},dispose:function(){if(this.get_insertButton()){$clearHandlers(this.get_insertButton());
}if(this.get_cancelButton()){$clearHandlers(this.get_cancelButton());
}Telerik.Web.UI.Widgets.FileManager.callBaseMethod(this,"dispose");
}};
b.registerControlProperties(a.Widgets.FileManager,{imageEditorFileSuffix:"",enableImageEditor:false,previewerType:null,cancelButton:null,insertButton:null,filePreviewer:null,fileBrowser:null,initialItem:null});
Telerik.Web.UI.Widgets.FileManager.registerClass("Telerik.Web.UI.Widgets.FileManager",Telerik.Web.UI.RadWebControl,Telerik.Web.IParameterConsumer);
Telerik.Web.UI.Widgets.FilePreviewer=function(c){Telerik.Web.UI.Widgets.FilePreviewer.initializeBase(this,[c]);
this._item=null;
};
Telerik.Web.UI.Widgets.FilePreviewer.prototype={initialize:function(){Telerik.Web.UI.Widgets.FilePreviewer.callBaseMethod(this,"initialize");
},setItem:function(c){this._item=c;
},getResult:function(){return this._item;
},_selectOptionByValue:function(h,e,f,d){if(typeof(d)=="undefined"){d=0;
}if(typeof(f)=="undefined"){f=false;
}e=f?c:e.toLowerCase();
h.selectedIndex=-1;
for(var g=0;
g<h.options.length;
g++){var c=h.options[g].value;
c=f?c:c.toLowerCase();
if(c==e){h.selectedIndex=g;
return;
}}h.selectedIndex=d;
},populateObjectProperties:function(c){},get_browser:function(){return this._browser;
},set_browser:function(c){this._browser=c;
},dispose:function(){Telerik.Web.UI.Widgets.FilePreviewer.callBaseMethod(this,"dispose");
}};
Telerik.Web.UI.Widgets.FilePreviewer.registerClass("Telerik.Web.UI.Widgets.FilePreviewer",Telerik.Web.UI.RadWebControl);
})();
